USE FixedAsset_Star
GO 
IF (SELECT object_id('dbo.Branch_Dim')) > 0
   DROP TABLE dbo.Branch_Dim
CREATE TABLE dbo.Branch_Dim
	(
	BranchKey		int IDENTITY (1,1) NOT NULL,
	BranchID		NVARCHAR (255) NOT NULL,
	AddressNumber 	INTEGER NOT NULL,
	BranchName		NVARCHAR (255) NOT NULL,
	BranchName1		NVARCHAR (255) NOT NULL
	)

IF (SELECT object_id('dbo.Department_Dim')) > 0
   DROP TABLE dbo.Department_Dim
CREATE TABLE dbo.Department_Dim
	(
	DepartmentKey	int IDENTITY (1,1) NOT NULL,
	DepartmentID	NVARCHAR (255) NOT NULL,
	DepartmentName	NVARCHAR (255) NOT NULL,
	DepartmentName1	NVARCHAR (255) NOT NULL
	)

IF (SELECT object_id('dbo.FixedAsset_Dim')) > 0
   DROP TABLE dbo.FixedAsset_Dim
CREATE TABLE dbo.FixedAsset_Dim
	(
	FixedAssetKey	int IDENTITY (1,1) NOT NULL,
	FixedAssetID	NVARCHAR (255) NOT NULL,
	FixedAssetName	NVARCHAR (255) NOT NULL,
	UnitNumber		NVARCHAR (255) NOT NULL,
	ParentNumber	NVARCHAR (255) NOT NULL,
	Description1	NVARCHAR (255) NOT NULL
	)


IF (SELECT object_id('dbo.Time_Dim')) > 0
   DROP TABLE dbo.Time_Dim
CREATE TABLE dbo.Time_Dim
	(
	TimeKey		int IDENTITY (1,1) NOT NULL,
	TheDate		datetime NOT NULL,
	DayOfWeek	nvarchar(20) NOT NULL,
	Month		int NOT NULL,
	Year		int NOT NULL,
	Quarter		int NOT NULL,
	DayOfYear	int NOT NULL,
	YearMonth	nvarchar(16) NOT NULL,
	WeekOfYear	int NOT NULL
	)
 	
 	
USE FixedAsset_Star
GO 
ALTER TABLE dbo.Branch_Dim WITH NOCHECK ADD
	CONSTRAINT PK_Branch_Dim
		PRIMARY KEY NONCLUSTERED(BranchKey)

ALTER TABLE dbo.Department_Dim WITH NOCHECK ADD
	CONSTRAINT PK_Department_Dim
		PRIMARY KEY NONCLUSTERED(DepartmentKey)

ALTER TABLE dbo.FixedAsset_Dim WITH NOCHECK ADD
	CONSTRAINT PK_FixedAsset_Dim
		PRIMARY KEY NONCLUSTERED(FixedAssetKey)

ALTER TABLE dbo.Time_Dim WITH NOCHECK ADD
	CONSTRAINT PK_Time_Dim
		PRIMARY KEY NONCLUSTERED(TimeKey)

GO